package Work2;
import java.util.Random;
import java.util.Scanner;

public class IsMaxnum {
	public static void main(String[] args) {
		int[][] arr = CreateArr();
		System.out.println("二维数组:");
		Thearr(arr);
		Ismax(arr);
	}
	
	public static int[][] CreateArr(){
		Random rd = new Random();
		Scanner sc =new Scanner(System.in);
		System.out.println("请输入二维数组大小");
		System.out.println("X:");
		int x=sc.nextInt();
		System.out.println("Y:");
		int y=sc.nextInt();
		int[][] arr = new int[x][y];
		for(int i=0;i<x;i++) {
			for(int j=0;j<y;j++) {
				arr[i][j]=rd.nextInt(100)+1;
			}
		}
		return arr;
	}
	
	public static void Ismax(int[][] arr) {
		for(int i=0;i<arr.length;i++) {
			int max = 0;
			int x=i,y=0;
			for(int j=0;j<arr[i].length;j++) {
				if(arr[i][j]>max) {
					max=arr[i][j];
					y=j;
				}
			}
			int t=0;
			for(int k=0;k<arr.length;k++) {
				if(arr[k][y]>max) {
					t=1;
					break;
				}
			}
			if(t==0) {
				System.out.printf("第%d行，第%d列的数%d,是该行该列的最大数\n",x+1,y+1,arr[x][y]);
			}
		}
	}
	
	public static void Thearr(int[][] a) {
		for(int i=0;i<a.length;i++) {
			for(int j=0;j<a[i].length;j++) {
				System.out.printf("%5d",a[i][j]);
			}
			System.out.printf("\n");
		}
	}
}
